import { ref } from 'vue'
export const useTable = (selectPageReq) => {
  /*define ref*/
  const tableListData = ref([])
  const total = ref<number>(0)
  const pageNum = ref(1)
  const pageSize = ref(20)


  //当前页
  const handleCurrentChange = (val) => {
    pageNum.value = val
    selectPageReq()
  }
  const handleSizeChange = (val) => {
    pageSize.value = val
    selectPageReq()
  }
  const resetPageReq = () => {
    pageNum.value = 1
    selectPageReq()
  }

  /*多选*/
  const multipleSelection = ref<Array<ObjKeys>>([])
  const handleSelectionChange = (val) => {
    multipleSelection.value = val
  }

  return {
    pageNum,
    pageSize,
    total,
    tableListData,
    multipleSelection,
    handleSelectionChange,
    handleCurrentChange,
    handleSizeChange,
    resetPageReq
  }
}
